package com.dragon.common.spring.openapi.customizers.operation;

import io.swagger.v3.oas.models.Operation;
import org.springdoc.core.customizers.OperationCustomizer;
import org.springframework.stereotype.Component;
import org.springframework.web.method.HandlerMethod;

/**
 * @author Chris Chan
 * Create On 2025/8/27 上午11:30
 * Use for: 为每个接口添加OperationId，格式为：类名_方法名
 * Explain:
 */
@Component
public class OperationIdOperationCustomizer implements OperationCustomizer {
    @Override
    public Operation customize(Operation operation, HandlerMethod handlerMethod) {
        String className = handlerMethod.getBeanType().getSimpleName();
        String methodName = handlerMethod.getMethod().getName();
        operation.setOperationId(className + "_" + methodName);
        return operation;
    }
}
